package com.jt.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MyMessageListener {

    private static final String EXCHANGE_NAME = "exchange-direct.order";
    private static final String QUEUE_NAME = "queue_order";
    private static final String ROUTING_KEY = "order";


    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = QUEUE_NAME, durable = "true"), exchange = @Exchange(value = EXCHANGE_NAME), key = {ROUTING_KEY}))
    public void processMessage(String dataString, Message message, Channel channel) {
        System.out.println("消费端接收到了消息1》》》》 "+dataString);
    }
}
